package collection2;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        Collection c=new ArrayList<>();
        c.add("1");
        c.add("*");
        c.add("2");
        c.add("*");
        c.add("3");
        c.add("*");

        System.out.println("以下的输出是用增强for输出的");
        for (Object o:c){
            System.out.println(o);
        }


        System.out.println("============以下是迭代器");
        Iterator i = c.iterator();
        while (i.hasNext()){
            String next =(String) i.next();
            if ("*".equals(next)){
                i.remove();
            }
        }
        System.out.println(c);

    }
}
